import ZmUpload from '@/components/ZmUpload/components/main'
export const base = info => {
  const isTypeFour = info.form.basicInfo.orderTypeId === '4'
  const isTypeThree = info.form.basicInfo.orderTypeId === '3'
  const isTypeSix = info.form.basicInfo.orderTypeId === '6'
  return [
    {
      name: '销售单名称',
      valueClass: 'vm  ',
      // label: 'customerName',
      render: (h, row, index) => {
        return [
          <el-button
            type="text"
            size="mini"
            class="pt10"
            onClick={() => {
              info.onExtendShow(info.form.basicInfo.orderId, 'sale')
            }}
          >
            {info.form.basicInfo.orderName}
          </el-button>
        ]
      }
    },
    { name: '销售单号', label: 'orderNo', valueClass: 'vm  ' },
    {
      name: '关联客户',
      valueClass: 'vm  ',
      // label: 'customerName',
      render: (h, row, index) => {
        return [
          <el-button
            type="text"
            size="mini"
            class="pt10"
            onClick={() => {
              info.onExtendShow(info.form.basicInfo.customerId, 'customer')
            }}
          >
            {info.form.basicInfo.customerName}
          </el-button>
        ]
      }
    },
    { name: '客户类型', label: 'customerTypeName', valueClass: 'vm  ' },
    { name: '签约主体', label: 'company', valueClass: 'vm  ' },
    { name: '合同形式', label: 'contractType', valueClass: 'vm  ' },
    // 销售单激活  新增业务场景字段
    {
      hide: !isTypeThree,
      name: '业务场景',
      label: 'businessSceneName',
      valueClass: 'vm  '
    },

    // 客情销售单增加附件上传 - 销售单激活
    {
      hasIcon: true,
      valueClass: 'vm  ',
      // hide: isTypeThree,
      name: '相关附件',
      render: h => {
        // const saleTypeList = ['1', '2', '3', '4', '5']
        return [
          <div class="df-center">
            <span class="dib" v-show={!info.form.basicInfo.enclosureUrl}>
              无附件
            </span>
            <zm-enclosure
              v-show={info.form.basicInfo.enclosureUrl}
              fileUrl={info.form.basicInfo.enclosureUrl}
            />
            <ZmUpload
              // v-show={saleTypeList.includes(context.saleOrderType)}
              class="ml5"
              http-request={info.fileUpload}
              accept=".rar,.zip,.doc,.docx,.pdf,.png,.jpg,.pptx"
              limit={1}
              single-file-size={5}
            >
              <zm-button size="mini">
                {!info.form.basicInfo.enclosureUrl ? '上传' : '替换'}
              </zm-button>
            </ZmUpload>
          </div>
        ]
      }
    },

    { name: '签单日期', label: 'signDate', valueClass: 'vm  ' },
    { name: '发票类型', label: 'invoiceType', valueClass: 'vm  ' },
    { name: '归属业务员', label: 'belongAccountName', valueClass: 'vm  ' },
    { name: '归属部门', label: 'belongDepartmentName', valueClass: 'vm  ' },
    { name: '预填开票主体', label: 'invoiceContent', valueClass: 'vm  ' },
    { name: '备注信息', label: 'remark', valueClass: 'vm  ' },
    {
      hide: !isTypeFour,
      name: '销售单总价',
      render: (h, row, index) => {
        return <span>{info.form.productInfo.saleTotalPrice}</span>
      }
    },
    {
      hide: !isTypeFour,
      name: '包场人数',
      render: (h, row, index) => {
        return <span>{info.form.productInfo.number}</span>
      }
    },
    {
      hide: !isTypeFour,
      name: '销售单单价',
      render: (h, row, index) => {
        return <span>{info.form.productInfo.salePrice}</span>
      }
    },
    {
      hide: !isTypeSix,
      name: '销售总额',
      render: (h, row, index) => {
        return <span>{info.form.basicInfo.saleOrderPrice || '-'}元</span>
      }
    },
    {
      hide: !isTypeFour,
      name: '最低销售单价',
      render: (h, row, index) => {
        return <span>{info.form.basicInfo.minSalePrice}</span>
      }
    },
    {
      hide: !isTypeFour,
      // hasIcon: isTypeFour,
      name: '预估提成',
      render: (h, row, index) => {
        return <span>{info.form.productInfo.proportionPrice}</span>
      }
    }
  ]
}

// 产品信息
export const product = info => {
  return [
    {
      name: '产品编号',
      label: 'productCode',
      toolFixed: true,
      valueClass: 'vm  '
    },

    {
      name: '产品名称',
      valueClass: 'vm  ',
      label: 'productName'
      /* render: (h, row, index) => {
        return [
          <el-button
            type="text"
            size="mini"
            class="pt10"
            onClick={() => {
              info.onExtendShow(info.form.productInfo.productId, "product");
            }}
          >
            {info.form.productInfo.productName}
          </el-button>
        ];
      } */
    },
    { name: '产品类型', label: 'productType', valueClass: 'vm  ' },
    { name: '业务类型', label: 'businessType', valueClass: 'vm  ' },

    {
      name: '次卡绑定产品',
      label: 'couponProductName',
      valueClass: 'vm  ',
      hide: info.form.productInfo.productTypeId !== '4'
    },

    { name: '售货方式', label: 'saleTypeName', valueClass: 'vm  ' }, // 次卡产品信息
    {
      hide: info.form.productInfo.productTypeId === '5',
      name: '产品面值',
      label: 'parValue',
      valueClass: 'vm  '
    },
    {
      hide: info.form.productInfo.productTypeId !== '5',
      name: '优惠券面值',
      label: 'parValue',
      valueClass: 'vm  '
    },

    {
      name: '理论成本',
      label: 'theoryCostPrice',
      valueClass: 'vm  ',
      unit: '%',
      hide: info.form.productInfo.productTypeId !== '3'
    },
    {
      name: '实际成本',
      label: 'practiceCostPrice',
      valueClass: 'vm  ',
      unit: '%',
      hide: info.form.productInfo.productTypeId !== '3'
    },
    {
      name: '销售比例',
      valueClass: 'vm  ',
      hide: info.form.productInfo.productTypeId !== '3',
      render: h => {
        return [
          <span>
            {info.form.productInfo.saleScalePrice +
              ':' +
              info.form.productInfo.saleScalePoint}
          </span>
        ]
      }
    },
    {
      name: '销售折扣',
      valueClass: 'vm  ',
      hide: info.form.productInfo.productTypeId !== '3',
      render: h => {
        return [<span>{info.form.productInfo.cardSaleScale || '--'}%</span>]
      }
    },
    {
      name: '消费比例',
      valueClass: 'vm  ',
      hide: info.form.productInfo.productTypeId !== '3',
      render: h => {
        return [
          <span>
            {info.form.productInfo.consumptionScalePrice +
              ':' +
              info.form.productInfo.consumptionScalePoint}
          </span>
        ]
      }
    },
    {
      hide: info.form.productInfo.productTypeId !== '3',
      name: '销售类型',
      render: h => {
        return [
          <span>
            {info.form.productInfo.isCustomize === '1'
              ? '自定义金额'
              : '统一金额'}
          </span>
        ]
      }
    },
    {
      name: '销售单价(元)',
      label: 'salePrice',
      valueClass: 'vm  ',
      hide: info.form.productInfo.productTypeId === '4'
    },
    {
      name: '销售单价(元)',
      label: 'salePriceName',
      valueClass: 'vm  ',
      hide: info.form.productInfo.productTypeId !== '4'
    },
    { name: '销售单总额(元)', label: 'saleTotalPrice', valueClass: 'vm  ' },
    { name: '数量(张)', label: 'number', valueClass: 'vm  ' },
    {
      hide: info.form.productInfo.productTypeId === '4', // 不为次卡
      name: '转赠配置',
      render: h => {
        return [
          <span>
            {info.form.productInfo.isGive === '1' ? '可转赠' : '不可转赠'}
          </span>
        ]
      }
    },
    { name: '提成', label: 'proportion', valueClass: 'vm  ' },
    { name: '预估提成(元)', label: 'proportionPrice', valueClass: 'vm  ' },
    { name: '有效期类型', label: 'expiredTypeName', valueClass: 'vm  ' },
    { name: '有效期', label: 'expireTime', valueClass: 'vm  ' },
    { name: '备注说明', label: 'remark', valueClass: 'vm  ' }
  ]
}

// 产品激活配置
export const active = info => {
  let productType = ''
  if (
    info.form.productInfo.productTypeId === '1' ||
    info.form.productInfo.productTypeId === '2' ||
    info.form.productInfo.productTypeId === '5'
  ) {
    productType = '券号区间'
  } else if (
    info.form.productInfo.productTypeId === '3' ||
    info.form.productInfo.productTypeId === '4'
  ) {
    productType = '卡号区间'
  }
  return [
    {
      name: '有效期类型',
      label: 'expiredTypeName',
      valueClass: 'vm  ',
      hide: info.form.basicInfo.orderTypeId === '4'
    },
    {
      name: '有效期',
      valueClass: 'vm  ',
      label: 'expireTime',
      hide: info.form.basicInfo.orderTypeId === '4'
    },
    {
      name: productType,
      // label: '',
      valueClass: 'vm  ',
      hide: info.form.activeInfo.saleType === '2',
      render: (h, v) => {
        const res = info.form.activeInfo.codeIdDetail.map(item => {
          return item.left + '-' + item.right
        })
        return <span>{res.join(',')}</span>
      }
    },
    { name: '激活操作人', label: 'activeAccountName', valueClass: 'vm  ' },
    { name: '激活时间', label: 'activeTime', valueClass: 'vm  ' }
  ]
}

// 文旅
export const wenlv = ctx => {
  return [
    {
      name: '活动类型',
      label: 'typeName'
    },
    {
      name: '活动场地',
      label: 'address'
    },
    {
      name: '活动时间',
      type: 'date',
      start: 'startTime',
      end: 'endTime'
    },
    {
      name: '销售单总价计算方式',
      label: 'calculationMethodName'
    },
    {
      name: '销售单单价',
      label: 'unitPrice'
    },
    {
      name: '活动人数',
      label: 'joinCount'
    },
    {
      name: '销售单总价',
      label: 'totalSalePrice'
    },
    {
      name: '活动备注',
      label: 'remark'
    }
  ]
}

export const customizePriceColumns = context => {
  return [
    {
      label: '自定义金额',
      minWidth: 100,
      render: (h, row, index) => {
        return [<span>金额{index + 1}</span>]
      }
    },
    {
      label: '销售单价',
      minWidth: 100,
      render: (h, row) => {
        return [<span class="ml5">￥{row.unitPrice}</span>]
      }
    },
    {
      label: '产品面值',
      minWidth: 100,
      render: (h, row, index) => {
        return [
          <span>
            内含{row.unitPrice}元,折合卡内点数{row.unitPoint}点
          </span>
        ]
      }
    },
    {
      prop: 'num',
      label: '数量(张)',
      minWidth: 100
    },
    {
      prop: 'totalPrice',
      label: '总额(元)',
      minWidth: 100
    }
  ]
}

export const cinemaInfoList = [
  {
    name: '选择影院',
    type: 'cinemaType'
  },
  {
    name: '影院',
    type: 'url'
  },
  {
    name: '影片',
    type: 'filmName'
  },
  {
    hasIcon: true,
    name: '包场时间',
    type: 'date',
    start: 'startDate',
    end: 'endDate'
  },
  {
    hasIcon: true,
    name: '影厅备注',
    label: 'hallRemark'
  }
]

export const cinemaColumns = ctx => {
  return [
    {
      prop: 'cinemaName',
      label: '影院名称'
    },
    {
      prop: 'cinemaCode',
      label: '影院编码'
    },
    {
      prop: 'interfaceName',
      label: '系统商'
    },
    {
      prop: 'cinemaLineName',
      label: '院线'
    },
    {
      label: '地区',
      render: (h, row) => {
        return [
          <span>
            {row.provinceName}-{row.cityName}-{row.countyName}
          </span>
        ]
      }
    }
  ]
}
